package ooday04;

public class AnimalTest {
    public static void main(String[] args) {

        Animal [] animals = new Animal[5];
        animals[0] = new   Dog("/*小黑*/", 2 ,"黑色");
        animals[1] = new   Dog("/*小白*/", 1 ,"白色");
        animals[2] = new Chick("/*黄鸡*/", 2 ,"黄色");
        animals[3] = new  Fish("/*黑鱼*/", 3 ,"黑色");
        animals[4] = new  Fish("/*黄鱼*/", 2 ,"黄色");
        for (int  i = 0;  i < animals.length;  i++) {
            System.out.println(animals[i].name);
            animals[i].drink();
        }


        System.out.println();
        Master m = new Master();
        for (int i = 0; i < animals.length; i++) {
            m.feed(animals[i]);
            if (animals[i] instanceof Dog ){
                Dog dog = (Dog)animals[i];
                dog.lookHome();
            }
            if(animals[i] instanceof Chick){
                Chick chick = (Chick) animals[i];
                chick.layEggs();
            }
            if (animals[i] instanceof Fish){
                Fish fish = (Fish)animals[i];
                fish.swim();
            }
        }

        /*Dog [] dogs = new Dog[3];
        dogs[0] = new Dog("小黑" , 2 ,"黑色");
        dogs[1] = new Dog("小白" , 1 ,"白色");
        dogs[2] = new Dog("小红" , 3 ,"红色");
        for (int i = 0; i < dogs.length; i++) {
            dogs[i].lookHome();
        }

        Chick [] chicks = new Chick[2];
        chicks[0] = new Chick("黄鸡" , 2 ,"黄色");
        chicks[1] = new Chick("红鸡" , 3 , "红色");
        for (int i = 0; i < chicks.length; i++) {
            chicks[i].layEggs();
        }

        Fish [] fish = new Fish[3];
        fish[0] = new Fish("黑鱼", 3 , "黑色");
        fish[1] = new Fish("红鱼", 4 , "红色");
        fish[2] = new Fish("黄鱼", 2 , "黄色");
        for (int i = 0; i < fish.length; i++) {
            fish[i].swim();
        }*/
    }
}
